﻿using System;
using Cinemachine;
using UnityEngine;

namespace Yoozoo.Gameplay.Liberty
{
    public class MainControllerComponent : MonoBehaviour
    {
        public Transform Mover;
        public CinemachineBrain CinemachineBrain;
        public ThirdPersonOrbitCamBasicMobile TpCameraController;
        public MoveBehaviourMobile TpMoveBehaviour;
        
        [SerializeField]
        private bool allowMovement = true;

        public bool AllowMovement
        {
            get
            {
                return allowMovement;
            }
            set
            {
                TpMoveBehaviour.allow = value;
                allowMovement = value;
            }
        }
        
        
        [SerializeField]
        private bool allowCameraOperation = true;

        public bool AllowCameraOperation
        {
            get
            {
                return allowCameraOperation;
            }
            set
            {
                TpCameraController.allow = value;
                allowCameraOperation = value;
            }
        }


        private void Awake()
        {
            if (TpMoveBehaviour)
            {
                TpMoveBehaviour.allow = allowMovement;
            }
            if (TpCameraController)
            {
                TpCameraController.allow = allowCameraOperation;
            }
        }

#if UNITY_EDITOR
        private void OnValidate()
        {
            if (TpMoveBehaviour)
            {
                TpMoveBehaviour.allow = allowMovement;
            }
            if (TpCameraController)
            {
                TpCameraController.allow = allowCameraOperation;
            }
        }
#endif
        
        
    }
}